import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

class MaxQueue {
    //队列的最大值

     public Queue<Integer> queue;
     public Deque<Integer> queue1;
    public MaxQueue() {
        queue=new LinkedList<>();
        queue1=new LinkedList<>();//最大值队列数组
    }  
    public int max_value() {
        if(queue1.isEmpty()){
            return -1;
        }
        return queue1.peekFirst();
    }
    public void push_back(int value) {
        while (!queue1.isEmpty() && queue1.peekLast() < value) {
            queue1.pollLast();
        }
         queue1.addLast(value);
         queue.offer(value);
    }
    public int pop_front() {
        if(queue.isEmpty()){
            return -1;
        }
        int val=queue.poll();
        if(val==queue1.peekFirst()){
            queue1.pollFirst();
        }
        return val;
    }
}
